package com.zbkj.admin.controller.platform.v2;

import com.zbkj.dal.base.page.CommonPage;
import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.dal.pojo.request.order.platform.PlatformPurchaseOrderQueryRequest;
import com.zbkj.dal.pojo.response.order.merchant.MerchantOrderPurchaseDetailNewResponse;
import com.zbkj.dal.pojo.response.order.platform.PlatformOrderPurchasePageNewResponse;
import com.zbkj.service.service.order.platform.AdminPlatformPurchaseOrderV2Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author wangzhengyan
 * @date 2024/4/12 9:11 PM
 */
@RestController
@Api(tags = "平台管理-买入订单")
@RequestMapping("/api/admin/platform/v2/order/purchase")
public class PlatformPurchaseOrderV2Controller {

    @Resource
    private AdminPlatformPurchaseOrderV2Service adminPlatformPurchaseOrderV2Service;

    // 订单列表
    @PreAuthorize("hasAuthority('platform:order:page:list')")
    @ApiOperation(value = "商户端买入订单分页列表") //配合swagger使用
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public CommonResult<CommonPage<PlatformOrderPurchasePageNewResponse>> getList(@RequestBody PlatformPurchaseOrderQueryRequest request) {
        return CommonResult.success(CommonPage.restPage(adminPlatformPurchaseOrderV2Service.getAdminPlatformOrderPurchaseList(request)));
    }

    // 订单详情
    @PreAuthorize("hasAuthority('merchant:order:detail')")
    @ApiOperation(value = "商户端买入订单详情") //配合swagger使用
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public CommonResult<MerchantOrderPurchaseDetailNewResponse> getDetail(@RequestParam("orderNo")String orderNo) {
        return CommonResult.success(adminPlatformPurchaseOrderV2Service.getAdminPlatformOrderPurchaseDetail(orderNo));
    }




}
